package com.yiji.fintech.musfinance.common.eventbus.listener;

import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.Subscribe;
import com.yiji.fintech.musfinance.common.eventbus.event.LogEvent;
import com.yiji.fintech.musfinance.common.eventbus.listener.base.BaseLogListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 日志打印监听器
 * Created by ouwen@yiji.com} on 2017/9/14.
 */
@Component
@Slf4j
public class LogListener extends BaseLogListener {
    private AsyncEventBus eventBus;
    @Autowired
    public LogListener(AsyncEventBus eventBus){
        this.eventBus = eventBus;
        eventBus.register(this);
    }
    @Subscribe
    @Override
    public void doExcute(LogEvent event) {
        switch (event.getL()){
            case INFO:
                log.info(event.getM(),event.getO());
                break;
            case DEBUG:
                log.debug(event.getM(),event.getO());
                break;
            case ERROR:
                log.error(event.getM(),event.getO());
                break;
            case WARN:
                log.warn(event.getM(),event.getO());
                break;
            case FATAL:
                break;
            case TRACE:
                break;
            case OFF:
                break;
        }
    }
}
